﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using System.Web.Script.Services;
using KishOnlineDomain.Controller;
using KishOnlineDomain.Common;
using KishOnlineCommone;


[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Authorize
{
    [OperationContract]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public ResultDTO<UserDTO> LoginCheck(string userName, string atttemptPass)
    {
      var res= new UserController().Loggin(userName, atttemptPass);
      var user = Utility.GetLogginSession();
      var result=new ResultDTO<UserDTO>();
      result.Data = user;
      result.IsSucceed = res.IsSucceed;
      result.Message = res.Message;
      return result;
    }

    [OperationContract]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public ResultDTO<UserDTO> GetCurrentUser()
    {
        var result = new ResultDTO<UserDTO>();
        var user = Utility.GetLogginSession();
        if (user != null)
        {
            result.Data = user;
            result.IsSucceed = true;
        }
        else
        {
            result.IsSucceed = false;
        }
        return result;
    }

    [OperationContract]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public ResultDTO LogOut()
    {
        return new UserController().LoggOut();
    }

    // Add more operations here and mark them with [OperationContract]
}
